﻿namespace WinKee.Models
{
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;

    using KeePassLib;

    [DataContract]
    public class PasswordGroup
    {
        public PasswordGroup(PwGroup group)
        {
            this.GroupName = group.Name;
            this.Entries = group.Entries.Select(e => new PasswordEntry(e)).OrderBy(e => e.Title).ToList();
            this.Groups = new List<PasswordGroup>();
            this.EntryCount = this.Entries.Count;
        }

        [DataMember]
        public int EntryCount { get; set; }

        [DataMember]
        public string GroupName { get; set; }

        [DataMember]
        public IList<PasswordEntry> Entries { get; set; }

        [DataMember]
        public IList<PasswordGroup> Groups { get; set; }
    }
}
